<template>
    <div class="do-flex-box">
        <el-card class="card-box">
            <template #header>
                <div class="card-header">
                    <span>考试</span>
                </div>
            </template>
            <el-select v-model="examType" placeholder="请选择" >
                <el-option v-for="item in examOptions" :key="item.id" :value="item.id" :label="item.value"></el-option>
            </el-select>
            
            <template #footer>
                <el-button type="primary" bg @click="submitExam">提交</el-button>
            </template>
        </el-card>

        <!-- <el-card class="card-box">
            <template #header>
                <div class="card-header">
                    <span>随机刷题</span>
                </div>
            </template>
            <div>多种模式都会刷，建议多执行几遍</div>
            <template #footer>
                <el-button type="primary" bg @click="doRandomDoQuestion">提交</el-button>
            </template>
        </el-card> -->

        <el-card class="card-box">
            <template #header>
                <div class="card-header">
                    <span>按类型刷题</span>
                </div>
            </template>
            <div>
                <el-select v-model="questionForm.type" placeholder="请选择" >
                    <el-option v-for="item in doTypeOptions" :key="item.type" :value="item.type" :label="item.msg"></el-option>
                </el-select>
                <!-- <el-input-number v-model="questionForm.startNum" :min="1" :max="1000"  style="margin-top: 20px;"/> -->
            </div>
            <template #footer>
                <el-button type="primary" bg @click="submitDoQuestionByType">提交</el-button>
            </template>
        </el-card>


        <el-card class="card-box">
            <template #header>
                <div class="card-header">
                    <span>签到</span>
                </div>
            </template>
            <div>签到获取积分</div>
            <template #footer>
                <el-button type="primary" bg @click="submitSign">提交</el-button>
            </template>
        </el-card>

        <el-card class="card-box">
            <template #header>
                <div class="card-header">
                    <span>每日视频</span>
                </div>
            </template>
            <div>看视频获取积分</div>
            <template #footer>
                <el-button type="primary" bg @click="submitCourseStudy">提交</el-button>
            </template>
        </el-card>

        <el-card class="card-box">
            <template #header>
                <div class="card-header">
                    <span>每日知识点</span>
                </div>
            </template>
            <div>查看“阅读学习”模考，获取积分</div>
            <template #footer>
                <el-button type="primary" bg @click="submitDayStudy">提交</el-button>
            </template>
        </el-card>


        <el-card class="card-box">
            <template #header>
                <div class="card-header">
                    <span>更新每日用户状态</span>
                </div>
            </template>
            <div>状态依赖官方服务器，所以要经常更新</div>
            <template #footer>
                <el-button type="primary" bg @click="reflushDayStatus">提交</el-button>
            </template>
        </el-card>

        <el-card class="card-box">
            <template #header>
                <div class="card-header">
                    <span>更新每月用户状态</span>
                </div>
            </template>
            <div>状态依赖官方服务器，所以要经常更新</div>
            <template #footer>
                <el-button type="primary" bg @click="reflushMonthStatus">提交</el-button>
            </template>
        </el-card>

        <el-card class="card-box">
            <template #header>
                <div class="card-header">
                    <span>更新用户做题时长</span>
                </div>
            </template>
            <div>做题时长依赖官方服务器，更新做题时长</div>
            <template #footer>
                <el-button type="primary" bg @click="reflushAddTime">提交</el-button>
            </template>
        </el-card>
    </div>
</template>

<script lang="ts" setup name="DoQuestion">

import { ref,reactive } from 'vue'
import { doExamApi,signInApi,courseStudyApi,studyKnowledgeOneApi,doQuestionByTypeApi,dayStatusApi, refaushDoTimeLenApi, dayMonthStatusApi } from '@/http/api/mk/mkDoQuestion';
import { type MyResponseType } from '@/bean/base/response';
import { ElMessage } from 'element-plus';

const examType = ref(1);
const examOptions = [{id:1,value:"模拟考试"},{id:2,value:"手机考试"}];

const questionForm = reactive({
    type:2,
    startNum:0
})

const doTypeOptions = [
    {type:0,msg:"顺序练习"},
    {type:1,msg:"随机练习"},
    {type:2,msg:"专项练习"},
    {type:3,msg:"未做选择题"}
];

function submitExam() {
    let params = {type:examType.value};
    doExamApi(params).then((res:MyResponseType<Object>)=>{
        if(res.code != 200) return;
        ElMessage({
            message: '操作成功',
            type: 'success',
        })
    });
}

function submitSign() {
    signInApi().then((res:MyResponseType<Object>)=>{
        if(res.code != 200) return;
        ElMessage({
            message: '操作成功',
            type: 'success',
        })
    });
}


function submitDoQuestionByType() {
    doQuestionByTypeApi(questionForm).then((res:MyResponseType<Object>)=>{
        if(res.code != 200) return;
        ElMessage({
            message: '操作成功',
            type: 'success',
        })
    });
}



function submitCourseStudy() {
    courseStudyApi().then((res:MyResponseType<Object>)=>{
        if(res.code != 200) return;
        ElMessage({
            message: '操作成功',
            type: 'success',
        })
    });
}

function submitDayStudy() {
    studyKnowledgeOneApi().then((res:MyResponseType<Object>)=>{
        if(res.code != 200) return;
        ElMessage({
            message: '操作成功',
            type: 'success',
        })
    });
}

function reflushDayStatus() {
    dayStatusApi().then((res:MyResponseType<Object>)=>{
        if(res.code != 200) return;
        ElMessage({
            message: '操作成功',
            type: 'success',
        })
    });
    
}


function reflushMonthStatus() {
    dayMonthStatusApi().then((res:MyResponseType<Object>)=>{
        if(res.code != 200) return;
        ElMessage({
            message: '操作成功',
            type: 'success',
        })
    });
}


function reflushAddTime() {
    refaushDoTimeLenApi().then((res:MyResponseType<Object>)=>{
        if(res.code != 200) return;
        ElMessage({
            message: '操作成功',
            type: 'success',
        })
    });
}


</script>

<style scoped>

.do-flex-box {
    display: flex;
    justify-content: start;
    flex-wrap: wrap;
    gap: 4%;
}
.card-box {
    width: 30%;
    min-width: 230px;
    margin-top: 20px;
}

@media (max-width: 600px) {
    .do-flex-box {
        display: flex;
        justify-content: center;
    }
}
</style>